package com.heima.sc.order.service;

import com.heima.sc.order.mapper.OrderMapper;
import com.itheima.sc.pojo.Order;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    private OrderMapper orderMapper;

    public List<Order> findOrderByUserName(String username){
        //1.参数校验
        if (StringUtils.isBlank(username)){
            return null;
        }
        //2.业务代码
        Example example=new Example(Order.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("username",username);
        List<Order> orderList = orderMapper.selectByExample(example);
        //3.封装返回结果
        return orderList;
    }
}
